<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <router-view></router-view>
  </div>
  <script src="./vue.js"></script>
  <script src="./vue-router.js"></script>
  <script>
    const user = {
      template: `
        <div>个人中心</div>
      `
    }
    const index = {
      template: `
        <div>
          <header>头部导航<router-link to="/user">个人中心</router-link></header>
          <router-view/>
          <footer>底部导航</footer>
        </div>
        
      `
    }
    
    const article = {
      template: `
        <div>文章详情{{$route.params.id}}</div>
      `
    }

    const channel = {
      template: `
        <div>列表{{$route.params.id}}</div>
      `
    }

    const routes = [
      {
        path: '/',
        component: index,
        redirect: '/article/100',
        children: [
          {
            path: 'article/:id',
            component: article
          }, {
            path: 'channel/:id',
            component: channel
          },
        ]
      },
      {
        path: '/user',
        component: user
      }
    ]
      
    const router = new VueRouter({
      routes
    })
    
    const app = new Vue({
      el: '#app',
      data: {},
      router
      
    })
    
  </script>
</body>
</html>